<style>

</style>
<div class="layui-layout order-wrapper" style="padding:0 20px;">
    <div id="search-wrapper">
        <div class="layui-form">
            <div class="layui-row">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" id="report_time" name="report_time"  placeholder="请输入日期" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <select name="channel" class="channel" lay-verify="">
                        <option value="-1">请选择频道</option>
                        <option value="1">男频</option>
                        <option value="2">女频</option>
                    </select>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn search" data-type="reload">搜索</button>
                </div>
                <div class="layui-inline fr">
                    <button class="layui-btn layui-btn-normal export">导出</button>
                </div>
            </div>
        </div>
    </div>
    <table class="layui-hide" id="table_list" lay-filter="table_filter">
    </table>
</div>
<script>
    layui.use(['table','laydate'], function(){
        var table = layui.table;
        var $ = layui.$;
        //方法级渲染
        table.render({
            elem: '#table_list'
            ,url: '/bookreport/table',
            where:{time:$("#report_time").val(),channel:$(".channel").val()}
            ,cols: [[
                {field:'sort', title: '序号', align:'center',width:'100',fixed:'left'},
                {field:'reportDate', title: '日报日期', align:'center',width:'120',fixed:'left'},
                {field:'bookId', title: '书Id', align:'center',width:'120',fixed:'left'},
                {field:'bookName', title: '书名', align:'center',width:'180',fixed:'left'},
                {field:'channel', title: '频道', align:'center',width:'100',templet: function(d){
                        if (d.channel == 1){
                            return "男频"
                        }else{
                            return "女频"
                        }
                    }},
                {field:'chapterPriceSum', title: '总价', align:'center',width:'120',sort:'true'},
                {field:'price', title: '单价', align:'center',width:'120',sort:'true'},
                {field:'status', title: '状态', align:'center',width:'120'},
                {field:'chapterTotal', title: '章节总数', align:'center',width:'120',sort:'true'},
                {field:'onlineChapter', title: '已更章节', align:'center',width:'120',sort:'true'},
                {field:'chapterStart', title: '始更章节', align:'center',width:'120',sort:'true'},
                {field:'chapterDaily', title: '日更章节', align:'center',width:'120',sort:'true'},
                {field:'releaseTime', title: '上架日期', align:'center',width:'180',sort:'true'},
                {field:'buyUsers', title: '购买人数', align:'center',width:'100',sort:'true'},
                {field:'buyCount', title: '购买人数', align:'center',width:'100',sort:'true'},
                {field:'readUsers', title: '阅读人数', align:'center',width:'100',sort:'true'},
                {field:'readCount', title: '阅读章节数', align:'center',width:'120',sort:'true'},
                // {field:'CommitDate', title: '订单支付时间', align:'center',width:'180',templet:function (d) {
                //         return (d.CommitDate + '').split("+")[0].replace("T"," ")
                //     }},
            ]]
            ,id: 'listReload'
            ,page: true
            ,height: "full-200"
        });

        var active = {
            reload: function(){
                table.reload('listReload', {
                    where:{
                        time:$("#report_time").val(),
                        channel:$(".channel").val()
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            }
        };

        var laydate = layui.laydate;
        laydate.render({
            elem: '#report_time',//选择器结束时间
            type: 'date'
        });

        $('#search-wrapper .search').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';

        });

        $(".export").click(function(){
            var dataTime = $("#report_time").val();
            if (dataTime == "") {
                layer.msg("请先选择日期");
                return
            }
            var urlParam = "?page=1&limit=99999999" + "&time=" + $("#report_time").val() + "&channel=" + $(".channel").val() + "&export=1";
            window.open('/bookreport/table'+urlParam)
        });

    })



</script>